
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32_TIM_H__
#define __STM32_TIM_H__

/**
  * @brief  
  * @note   依赖于STM32CubeMX生成的tim.h文件，主要是用到了STM32CubeMX
  *         生成tim.h头文件中的串口的底层配置函数HAL_TIM_MspInit，用户
  *         也可以自己实现HAL_TIM_MspInit函数
  *
  */
	
#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "tim.h"
#include "stm32_uart.h"


typedef enum
{
  TIM_STATUS_IDLE = 0,
  TIM_STATUS_BUSY = 1,
  TIM_STATUS_UPDATE = 2,
} TIM_Status_t;


#if (UART_RECEIVE_FRAME_MODE == USE_TIM_UPDATE_RECEIVE_UART_FRAME)

#if (STM32_LPUART1_ENABLE == 1)
#define TIM_HANDLE_LPUART1_RX          htim3
#define TIM_PERIPHERAL_LPUART1_RX      TIM3
extern TIM_Status_t TIM_Status_LPUART1_RX;
#endif

#if (STM32_UART1_ENABLE == 1)
#define TIM_HANDLE_UART1_RX            htim16
#define TIM_PERIPHERAL_UART1_RX        TIM16
extern TIM_Status_t TIM_Status_UART1_RX;
#endif

#if (STM32_UART2_ENABLE == 1)
#define TIM_HANDLE_UART2_RX            htim5
#define TIM_PERIPHERAL_UART2_RX        TIM5
extern TIM_Status_t TIM_Status_UART2_RX;
#endif

#if (STM32_UART3_ENABLE == 1)
#define TIM_HANDLE_UART3_RX            htim6
#define TIM_PERIPHERAL_UART3_RX        TIM6
extern TIM_Status_t TIM_Status_UART3_RX;
#endif

#if (STM32_UART4_ENABLE == 1)
#define TIM_HANDLE_UART4_RX            htim7
#define TIM_PERIPHERAL_UART4_RX        TIM7
extern TIM_Status_t TIM_Status_UART4_RX;
#endif

#if (STM32_UART5_ENABLE == 1)
#define TIM_HANDLE_UART5_RX            htim8
#define TIM_PERIPHERAL_UART5_RX        TIM8
extern TIM_Status_t TIM_Status_UART5_RX;
#endif

#if (STM32_UART6_ENABLE == 1)
#define TIM_HANDLE_UART6_RX            htim9
#define TIM_PERIPHERAL_UART6_RX        TIM9
extern TIM_Status_t TIM_Status_UART6_RX;
#endif

#if (STM32_UART7_ENABLE == 1)
#define TIM_HANDLE_UART7_RX            htim5
#define TIM_PERIPHERAL_UART7_RX        TIM5
extern TIM_Status_t TIM_Status_UART7_RX;
#endif

#if (STM32_UART8_ENABLE == 1)
#define TIM_HANDLE_UART8_RX            htim12
#define TIM_PERIPHERAL_UART8_RX        TIM12
extern TIM_Status_t TIM_Status_UART8_RX;
#endif

#endif


void STM32_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
int32_t STM32_TIM_Init(TIM_TypeDef *STM32_TIM, TIM_HandleTypeDef *htim, uint32_t psc, uint32_t arr);


#ifdef __cplusplus
}
#endif

#endif


